package com.sskj.b70.m.http;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.b70.MyAppLication;
import com.sskj.b70.common.Constants;
import com.sskj.b70.m.HttpConfig;
import com.sskj.b70.m.StockCoinBean;
import com.sskj.b70.m.bean.AddressList;
import com.sskj.b70.m.bean.AgentNumBean;
import com.sskj.b70.m.bean.AppVersionBean;
import com.sskj.b70.m.bean.AseetListBean;
import com.sskj.b70.m.bean.Banner;
import com.sskj.b70.m.bean.CapitalDetailData;
import com.sskj.b70.m.bean.CoinFee;
import com.sskj.b70.m.bean.CoinFeeBean;
import com.sskj.b70.m.bean.CommissionBean;
import com.sskj.b70.m.bean.CustomListBean;
import com.sskj.b70.m.bean.DagBean;
import com.sskj.b70.m.bean.Entrust;
import com.sskj.b70.m.bean.FabiBuyBean;
import com.sskj.b70.m.bean.FabiDetailListBean;
import com.sskj.b70.m.bean.FabiListBean;
import com.sskj.b70.m.bean.FabiOrderBean;
import com.sskj.b70.m.bean.FabiPublishListBean;
import com.sskj.b70.m.bean.HaiPageBean;
import com.sskj.b70.m.bean.HttpData;
import com.sskj.b70.m.bean.LevelVolumeBean;
import com.sskj.b70.m.bean.Notice;
import com.sskj.b70.m.bean.NoticeList;
import com.sskj.b70.m.bean.PageData;
import com.sskj.b70.m.bean.PayWayBean;
import com.sskj.b70.m.bean.RechargeInfoBean;
import com.sskj.b70.m.bean.SocketSendBean;
import com.sskj.b70.m.bean.StockBean;
import com.sskj.b70.m.bean.SysConfigBean;
import com.sskj.b70.m.bean.TradeInfoBean;
import com.sskj.b70.m.bean.TradePositionListBean;
import com.sskj.b70.m.bean.TransactionModel;
import com.sskj.b70.m.bean.UserBean;
import com.sskj.b70.m.bean.UserCoinInfo;
import com.sskj.b70.m.bean.UserInfo;
import com.sskj.b70.m.bean.XiTongBean;
import com.sskj.b70.m.bean.bean.FbShop;
import com.sskj.b70.p.activity.InviteFriendPresenter;
import com.sskj.b70.utils.APKVersionCodeUtils;
import com.sskj.b70.utils.SPUtils;

import java.io.File;
import java.util.HashMap;
import java.util.List;

import okhttp3.WebSocket;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-07-27 11:05
 */
public class HttpUtil implements IHttpService {
    // 登录接口
    @Override
    public PostRequest<HttpData<UserBean>> login(String mobile, String pws) {
        return OkGo.<HttpData<UserBean>>post(HttpConfig.BASE_URL + HttpConfig.LOGIN)
                .params("mobile", mobile)
                .params("opwd", pws)
                .params("account", mobile)
                .params("pswd", pws);
    }

    // 注册  获取验证码
    @Override
    public GetRequest<HttpData> sendCode(String mobile, String type) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SMS_SEND)
                .params("mobile", mobile)
                .params("type", type)
                .params("codeType", type)
                .params("account", mobile);
    }

    @Override
    public WebSocketObserver pushCoinType(String type) {
        return new WebSocketObserver(HttpConfig.WS_STOCK) {
            @Override
            public void onOpen(WebSocket webSocket, okhttp3.Response response) {
                webSocket.send(new Gson().toJson(new SocketSendBean(type)));
            }
        };
    }

    @Override
    public WebSocketObserver pushCoinFive(String type) {
        return new WebSocketObserver(HttpConfig.WS_STOCK) {
            @Override
            public void onOpen(WebSocket webSocket, okhttp3.Response response) {
                webSocket.send(new Gson().toJson(new SocketSendBean(type)));
            }
        };
    }

    //注册确定按钮
    @Override
    public PostRequest<HttpData> registerConfirm(String account, String pswd, String code, String invitationCode) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.REGISTER)
                .params("code", code)
                .params("account", account)
                .params("pswd", pswd)
                .params("invitationCode", invitationCode);
    }

    /**
     * 实名认证
     */
    @Override
    public PostRequest<HttpData> verifyIdentConfirm(String realName, String identNum, HashMap<String, Object> params) {
        String mobile = (String) SPUtils.get(MyAppLication.getApplication(), Constants.SP_MOBILE, "");
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.IDENT_AUTH)
                .isMultipart(false)
                .params("realname", realName)
                .params("mobile", mobile)
                .params("idcard", identNum)
                .params("image3", (File) params.get("photo_a"), (String) params.get("photoAName"))
                .params("image1", (File) params.get("photo_b"), (String) params.get("photoBName"))
                .params("image2", (File) params.get("photo_c"), (String) params.get("photoCName"))
                .params("username", realName)
                .params("idCardNo", identNum)
                .params("selfieImgUrl", (File) params.get("photo_a"), (String) params.get("photoAName"))
                .params("idCardFrontImgUrl", (File) params.get("photo_b"), (String) params.get("photoBName"))
                .params("idCardBackImgUrl", (File) params.get("photo_c"), (String) params.get("photoCName"));
    }

    /**
     * 安全中心重置密码
     */
    @Override
    public GetRequest<HttpData> resetPwd(String account, String passwordOrigin, String password) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.CHANGE_PWD)
                .params("oldpwd", passwordOrigin)
                .params("opwd", password)
                .params("opwd1", password)
                .params("account", account)
                .params("pswd", passwordOrigin)
                .params("newPswd", password);
    }


    @Override
    public PostRequest<HttpData<HaiPageBean<FabiListBean>>> getFbList(int page, int size, boolean isBuy) {
        return OkGo.<HttpData<HaiPageBean<FabiListBean>>>post(HttpConfig.BASE_URL + HttpConfig.FABI_LIST)
                .params("type", isBuy ? "pmma" : "sell")
                .params("p", page)
                .params("size", size)
                .params("id", MyAppLication.getID())
                .params("tradeType", isBuy ? "1" : "2");
    }

    @Override
    public GetRequest<HttpData<HaiPageBean<TradePositionListBean>>> getBillList(int type) {
        return OkGo.<HttpData<HaiPageBean<TradePositionListBean>>>get(HttpConfig.BASE_URL + HttpConfig.TRADE_POSITION_LIST)
                .params("mobile", MyAppLication.getMobile())
                .params("type", type);
    }

    @Override
    public PostRequest<HttpData> createLevelOrder(StockBean stockData,
                                                  String entrustLot,
                                                  String buyPrice,
                                                  String stockCode,
                                                  int billPriceType,
                                                  int buyBillType,
                                                  String stopProfit,
                                                  String stopLoss,
                                                  boolean isTime) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TRADE_LEVEL_CREATE)
                .params("mobile", MyAppLication.getMobile())
                .params("newprice", stockData.newprice)
                .params("type", stockData.type)
                .params("buynum", Integer.valueOf(stockData.buynum))
                .params("shopname", isTime ? stockData.shopname : stockData.shopname.toLowerCase())
                .params("otype", stockData.otype)
                .params("zy", stockData.stopwin)
                .params("zs", stockData.stoploss)
                .params("entrustLot", entrustLot)
                .params("buyPrice", buyPrice)
                .params("stockCode", stockCode)
                .params("billPriceType", billPriceType)
                .params("buyBillType", buyBillType)
                .params("stopProfit", stopProfit)
                .params("stopLoss", stopLoss);
    }

    @Override
    public PostRequest<HttpData> cancelLevelOrder(String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TRADE_LEVEL_CANCEL)
                .params("mobile", MyAppLication.getMobile())
                .params("order_id", id)
                .params("orderId", id);
    }

    @Override
    public PostRequest<HttpData> closeLevelOrder(String hold_id, String newPrice) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TRADE_LEVEL_PINGCANG)
                .params("mobile", MyAppLication.getMobile())
                .params("order_id", hold_id)
                .params("orderId", hold_id)
                .params("newprice", newPrice);
    }

    @Override
    public GetRequest<HttpData> getTradeSms(String account) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SMS_SEND)
                .params("mobile", account)
                .params("type", 4)
                .params("account", account);
    }

    @Override
    public PostRequest<HttpData> setTradePwd(String id, String tradePwd, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.SET_PAY_PWD)
//                .params("mobile", MyAppLication.getMobile())
//                .params("account", MyAppLication.getAccount())
//                .params("tpwd", pwd1)
//                .params("tpwd1", pwd1)
//                .params("code", code)
                .params("id", id)
                .params("account", MyAppLication.getMobile())
                .params("code", code)
                .params("tradePwd", tradePwd);
    }

    @Override
    public PostRequest<HttpData> applyShop(String id, String isShopStatus) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.APPLY_SELLER)
                .params("id", id)
                .params("isShopStatus", isShopStatus);
    }

    @Override
    public PostRequest<HttpData<List<FbShop>>> moneyUsed(String name, String type) {
        return OkGo.<HttpData<List<FbShop>>>post(HttpConfig.BASE_URL + HttpConfig.FB_SHOP)
                .params("name", name)
                .params("type", type);
    }

    @Override
    public PostRequest<HttpData<List<PayWayBean>>> getPayList() {
        return OkGo.<HttpData<List<PayWayBean>>>post(HttpConfig.BASE_URL + HttpConfig.PAY_WAY_LIST)
                .params("id", MyAppLication.getID());
    }


    @Override
    public PostRequest<HttpData<List<StockCoinBean>>> getProduct(String code) {
        return OkGo.<HttpData<List<StockCoinBean>>>post(HttpConfig.BASE_URL + HttpConfig.PRODUCT_LIST)
                .params("type", 4)
                .params("code", code);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<NoticeList>>> getGGList(int number) {
        return OkGo.<HttpData<HaiPageBean<NoticeList>>>post(HttpConfig.BASE_URL + HttpConfig.NOTICE);
    }

    @Override
    public PostRequest<HttpData<Notice>> ggDetail(String id) {
        return OkGo.<HttpData<Notice>>post(HttpConfig.BASE_URL + HttpConfig.NOTICEDETAIL)
                .params("id", id);
    }

    @Override
    public PostRequest<HttpData> applyAgent(String id, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.APPLY_AGENT)
                .params("mobile", MyAppLication.getMobile())
                .params("code", code)
                .params("id", id)
                .params("account", MyAppLication.getMobile());
    }

    @Override
    public GetRequest<HttpData<AgentNumBean>> applyAgentList() {
        return OkGo.<HttpData<AgentNumBean>>get(HttpConfig.BASE_URL + HttpConfig.AGENT_INFO)
                .params("account", MyAppLication.getMobile())
                .params("id", MyAppLication.getID());
    }

    @Override
    public GetRequest<HttpData<HaiPageBean<CommissionBean>>> agentMoneyDetail(int page, String dateFrom, String dateTo) {
        return OkGo.<HttpData<HaiPageBean<CommissionBean>>>get(HttpConfig.BASE_URL + HttpConfig.AGENT_COSTUM)
                .params("act", "commission_info")
                .params("startDate", dateFrom)
                .params("endDate", dateTo)
                .params("p", page)
                .params("size", Constants.PAGE_SIZE)
                .params("id", MyAppLication.getID());
    }

    @Override
    public GetRequest<HttpData<HaiPageBean<CustomListBean>>> myClient(int page) {
        return OkGo.<HttpData<HaiPageBean<CustomListBean>>>get(HttpConfig.BASE_URL + HttpConfig.AGENT_COSTUM_CLIENT);
    }

    @Override
    public PostRequest<HttpData> createFabiOrder(String type, String sumCount, String lowCount, String hightCount, String unitPrice, int payWx, int payAli, int payBank, String remark) {
        StringBuilder stringBuilder = new StringBuilder();
        if (type.equals("2")) {
            if (payWx == 1) {
                stringBuilder.append("1,");
            }
            if (payAli == 1) {
                stringBuilder.append("2,");
            }
            if (payBank == 1) {
                stringBuilder.append("3,");
            }
            stringBuilder = stringBuilder.deleteCharAt(stringBuilder.lastIndexOf(","));
        }
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.PUBLISH)
                .params("account", MyAppLication.getAccount())
                .params("trans_num", sumCount)
                .params("min_price", lowCount)
                .params("max_price", hightCount)
                .params("price", unitPrice)
                .params("pay_wx", payWx)
                .params("pay_alipay", payAli)
                .params("pay_backcard", payBank)
                .params("notes", remark)
                .params("remarkInfo", remark)
                .params("type", type)
                .params("tradeType", type)
                .params("minPrice", lowCount)
                .params("maxPrice", hightCount)
                .params("transNum", sumCount)
//                .params("tradePwd", MD5Utils.getMd5Value("a1234567"))
                .params("price", unitPrice)
                .params("payType", stringBuilder.toString());
    }

    @Override
    public PostRequest<HttpData<Object>> addZhiFu(HttpParams params) {
        return OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.ADD_PAY_PWD)
                .params(params);
    }

    @Override
    public PostRequest<HttpData> cancelFabiPublishOrder(boolean isBuy, String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FABI_PUBLISH_ORDER_CANCLE)
                .params("orderId", id)
                .params("tradeType", isBuy ? 1 : 2)
                .params("type", isBuy ? "pmma" : "sell");
    }

    @Override
    public PostRequest<HttpData> cancelFabiTradeOrder(String orderNum) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FABI_ORDER_CANCLE)
                .params("order_num", orderNum)
                .params("orderId", orderNum)
                .params("id", MyAppLication.getID());
    }

    @Override
    public PostRequest<HttpData<UserCoinInfo>> getCoinTypeInfo(String code) {
        return OkGo.<HttpData<UserCoinInfo>>post(HttpConfig.BASE_URL + HttpConfig.ONE_COIN_INFO)
                .params("stockCode", code);
    }

    @Override
    public PostRequest<HttpData<String>> creatCoinOrder(String code, String price, String num, int tradeType, int billPriceType) {
        return OkGo.<HttpData<String>>post(HttpConfig.BASE_URL + HttpConfig.CREATE_COIN_ORDER)
                .params("code", code)
                .params("tradeType", tradeType)
                .params("billPriceType", billPriceType)
                .params("stockCode", code)
                .params("entrustNum", num)
                .params("entrustPrice", price);
    }

    @Override
    public PostRequest<HttpData> closeOrUp(PayWayBean item) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CHANGE_SWITCH)
                .params("type", item.getType())
                .params("val", item.getStatus())
                .params("account", MyAppLication.getAccount())
                .params("id", MyAppLication.getID())
                .params("payId", item.getId())
                .params("disable", !item.isDisable());
    }


    @Override
    public PostRequest<HttpData<List<XiTongBean>>> aboutMine() {
        return OkGo.<HttpData<List<XiTongBean>>>post(HttpConfig.BASE_URL + HttpConfig.FB_SHOP)
                .params("type", "9")
                .params("name", "platform_email");
    }

    @Override
    public GetRequest<HttpData<AddressList>> coinList() {
        return OkGo.<HttpData<AddressList>>get(HttpConfig.BASE_URL + HttpConfig.ADDRESS_LIST)
                .params("stockUserId", MyAppLication.getID());
    }

    @Override
    public PostRequest<HttpData> addCoin(String address, String notes, String account, String type,String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADDRESS_ADD)
                .params("type", type)
                .params("addr", address)
                .params("code", code)
                .params("remark", notes)
                .params("stockUserId", MyAppLication.getID());

    }


    @Override
    public PostRequest<HttpData> deleteCoin(String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADDRESS_DEL)
                .params("id", id)
                .params("act", "del");
    }

    @Override
    public PostRequest<HttpData<InviteFriendPresenter.QRBean>> inviteCodeUrl(String id) {
        return OkGo.<HttpData<InviteFriendPresenter.QRBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_INVITE_URL)
                .params("mobile", MyAppLication.getMobile());
    }

    @Override
    public PostRequest<HttpData<List<AseetListBean.AseetBean>>> assetList(String id) {
        return OkGo.<HttpData<List<AseetListBean.AseetBean>>>post(HttpConfig.BASE_URL + HttpConfig.ASEET_LIST)
                .params("id", id);
    }


    @Override
    public PostRequest<HttpData<CapitalDetailData>> assetListDetail(String assetId, String stockCode, int page) {
        return OkGo.<HttpData<CapitalDetailData>>post(HttpConfig.BASE_URL + HttpConfig.ASSET_RECORD_LIST)
                .params("mobile", MyAppLication.getMobile())
                .params("pid", assetId)
                .params("p", page)
                .params("id", assetId)
                .params("stockCode", stockCode);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<FabiPublishListBean>>> getFabiPublishOrderList(int page, boolean isBuy, String startTime, String endTime) {
        return OkGo.<HttpData<HaiPageBean<FabiPublishListBean>>>post(HttpConfig.BASE_URL + HttpConfig.FABI_PUBLISH_ORDER_LIST)
                .params("app", "app")
                .params("action", "brokerInfo")
                .params("type", isBuy ? "pmma" : "sell")
                .params("p", page)
                .params("size", 15)
                .params("b_time", startTime)
                .params("e_time", endTime)
                .params("tradeType", isBuy ? 1 : 2)
                .params("startDate", startTime)
                .params("endDate", endTime);
    }

    @Override
    public GetRequest<HttpData<CapitalDetailData>> czAndTx(String assetId, String stockCode, String type, int page) {
        return OkGo.<HttpData<CapitalDetailData>>get(HttpConfig.BASE_URL + HttpConfig.RECHARGE_LIST)
                .params("mobile", MyAppLication.getMobile())
                .params("pid", assetId)
                .params("p", page)
                .params("type", type)
                .params("id", assetId)
                .params("stockCode", stockCode);
    }

    @Override
    public PostRequest<HttpData<RechargeInfoBean>> czDetail(String type, String code) {
        return OkGo.<HttpData<RechargeInfoBean>>post(HttpConfig.BASE_URL + HttpConfig.RECHARGE_URL)
//                .params("mobile", MyAppLication.getMobile())
//                .params("pid", id)
                .params("id", MyAppLication.getID())
                .params("code", code)
                .params("type", type);
    }


    @Override
    public PostRequest<HttpData<List<SysConfigBean>>> getSysConfig(int type) {
        return OkGo.<HttpData<List<SysConfigBean>>>post(HttpConfig.BASE_URL + HttpConfig.SYS_CONFIG)
                .params("type", type);
    }

    @Override
    public GetRequest<HttpData<TradeInfoBean>> getCapitalInfo() {
        return OkGo.<HttpData<TradeInfoBean>>get(HttpConfig.BASE_URL + HttpConfig.TRADE_INFO)
                .tag(this)
                .params("mobile", MyAppLication.getMobile());
    }

    @Override
    public PostRequest<HttpData<CoinFeeBean>> getCoin(String code) {
        return OkGo.<HttpData<CoinFeeBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_COIN_FEE)
                .params("code", code);
    }

    @Override
    public PostRequest<HttpData> extractCoin(String id, String usdFee, String tradePwd, String code, String walletAddr, String stockCode) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.WITHDRAW)
                .params("id", id)
                .params("usdFee", usdFee)
                .params("tradePwd", tradePwd)
                .params("code", code)
                .params("walletAddr", walletAddr)
                .params("stockCode", stockCode);
    }


    @Override
    public PostRequest<HttpData<TransactionModel>> getPankou(String code) {
        return OkGo.<HttpData<TransactionModel>>post(HttpConfig.BASE_URL + HttpConfig.COIN_PANKOU_LIST)
                .params("code", code);
    }

    @Override
    public PostRequest<HttpData<FabiBuyBean>> coinOrder(String tpwd, String order_no, String total_num, String total_price, int isBuy, String id, String payType) {
        return OkGo.<HttpData<FabiBuyBean>>post(HttpConfig.BASE_URL + HttpConfig.CREATE_FABI_ORDER)
//                .params("tpwd", tpwd)
//                .params("order_no", order_no)
//                .params("total_num", total_num)
//                .params("total_price", total_price)
//                .params("type", isBuy)
                .params("tradePwd", tpwd)     // 交易密码   委托单号  数量  价钱  出售/求购  id  支付方式
                .params("entrustNo", order_no)
                .params("transNum", total_num)
                .params("totalPrice", total_price)
                .params("tradeType", isBuy)
                .params("id", id)
                .params("payType", payType);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<Entrust>>> getCoinEntrustList(String code, String tradeType, String state) {
        return OkGo.<HttpData<HaiPageBean<Entrust>>>post(HttpConfig.BASE_URL + HttpConfig.COIN_ENTRUST_LIST)
                .params("code", code)
                .params("stockCode", code)
                .params("tradeType", tradeType)
                .params("state", state);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<Entrust>>> getCoinEntrustListAll(String code, String tradeType, String state) {
        return OkGo.<HttpData<HaiPageBean<Entrust>>>post(HttpConfig.BASE_URL + HttpConfig.COIN_ENTRUST_LIST_ALL)
                .params("code", code)
                .params("stockCode", code)
                .params("tradeType", tradeType)
                .params("stateStr", state);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<Entrust>>> getCoinEntrustingList(String code) {
        return OkGo.<HttpData<HaiPageBean<Entrust>>>post(HttpConfig.BASE_URL + HttpConfig.COIN_ENTRUSTING_LIST)
                .params("code", code)
                .params("stockCode", code);
    }

    @Override
    public PostRequest<HttpData<FabiOrderBean>> tradeListDetail(String tradeType, String entrustNo) {
        return OkGo.<HttpData<FabiOrderBean>>post(HttpConfig.BASE_URL + HttpConfig.ORDER_LIST_BUY)
//                .params("p", page)
//                .params("size", size);
                .params("id", MyAppLication.getID())
                .params("entrustNo", entrustNo)
                .params("tradeType", tradeType);
    }

    @Override
    public PostRequest<HttpData<HaiPageBean<FabiDetailListBean>>> tradeList(String tradeType, String entrustNo) {
        return OkGo.<HttpData<HaiPageBean<FabiDetailListBean>>>post(HttpConfig.BASE_URL + HttpConfig.ORDER_LIST_BUY)
                .params("id", MyAppLication.getID())
                .params("entrustNo", entrustNo)
                .params("tradeType", tradeType);
    }

    @Override
    public PostRequest<HttpData> endTrade(String id, String entrustNo) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FABI_ORDER_MARK_PAY)
                .params("order_no", entrustNo)
                .params("account", MyAppLication.getAccount())
                .params("id", id)
                .params("orderId", entrustNo);
    }

    @Override
    public PostRequest<HttpData> ssReason(String id, String tradeId, String ssType, String mark) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FABI_ORDER_ALLEGE)
//                .params("order_num", orderNum)
//                .params("refer", refer)
//                .params("shop_account", shop_account)
//                .params("ss_type", ss_type)
//                .params("ss_reason", ss_reason)
//                .params("orderId", orderNum)
//                .params("reason", ss_reason);
                .params("id", id)
                .params("orderId", tradeId)
                .params("type", ssType)
                .params("reason", mark);
    }

    @Override
    public PostRequest<HttpData> confirmFx(String id, String tradeId, String tradePwd) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FABI_ORDER_LET_GO)
//                .params("order_no", orderNum)
//                .params("tpwd", pwd);
                .params("id", id)
                .params("orderId", tradeId)
                .params("tradePwd", tradePwd);
    }

    @Override
    public GetRequest<HttpData<List<LevelVolumeBean>>> getLevelVolumeList(String code, int page) {
        return OkGo.<HttpData<List<LevelVolumeBean>>>get(HttpConfig.BASE_URL + HttpConfig.TRADE_LEVEL_VOLUME)
                .params("code", code)
                .params("page", page)
                .params("pageSize", 20);
    }

    @Override
    public PostRequest<HttpData<String>> cancelCoinOrder(int tradeType, String order_id) {
        return OkGo.<HttpData<String>>post(HttpConfig.BASE_URL + HttpConfig.COIN_ORDER_CANCEL)
                .params("orderId", order_id)
                .params("tradeType", tradeType);
    }

    @Override
    public PostRequest<HttpData<List<CoinFee>>> getCoinFee(String name) {
        return OkGo.<HttpData<List<CoinFee>>>post(HttpConfig.BASE_URL + HttpConfig.COIN_FEE)
                .params("type", 4)
                .params("name", name);


    }

    @Override
    public PostRequest<HttpData<Banner>> getBannerImage() {
        return OkGo.<HttpData<Banner>>post(HttpConfig.BASE_URL + HttpConfig.COIN_FEE)

                .params("type", 10);
    }

    @Override
    public PostRequest<HttpData> sendEmailCode(String email) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.SEND_EMAIL_CODE)

                .params("email", email);

    }

    @Override
    public PostRequest<HttpData> registerWithEmail(String email, String password, String code, String invitationCode) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.REGISTER_WITH_EMAIL)

                .params("email", email)
                .params("pswd", password)   // 最开始接口传两个密码
                .params("code", code)
                .params("invitationCode", invitationCode);

    }

    @Override
    public PostRequest<HttpData<UserBean>> loginWithEmail(String mobile, String pws) {
        return OkGo.<HttpData<UserBean>>post(HttpConfig.BASE_URL + HttpConfig.REGISTER_WITH_EMAIL)

                .params("email", mobile)
                .params("pswd", pws);
    }

    @Override
    public PostRequest<HttpData> bindMobile(String mobile, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.BIND_MOBILE)
                .params("id", MyAppLication.getID())
                .params("account", mobile)
                .params("code", code);
    }

    @Override
    public GetRequest<HttpData<PageData<DagBean>>> getDagList(int page, int type) {

        return OkGo.<HttpData<PageData<DagBean>>>get(HttpConfig.BASE_URL + (type == 0 ? HttpConfig.DAG_LIST_CHARGE : HttpConfig.DAG_LIST_MONEY))
                .params("id", MyAppLication.getID())
                .params("page", page)
                .params("pageSize", 15);
    }

    @Override
    public PostRequest<HttpData> resetPwdWithEmail(String email, String pwd, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.RESET_PWD_WITH_EMAIL)
                .params("email", email)
                .params("pswd", pwd)   // 最开始接口传两个密码
                .params("code", code);
    }

    @Override
    public PostRequest<HttpData<String>> uploadImg(File file) {

        return OkGo.<HttpData<String>>post(HttpConfig.BASE_URL + HttpConfig.UPLOAD_IMG)
                .params("file", file);

    }

    @Override
    public PostRequest<HttpData> checkIdent(String username, String idCardNo, String idCardFrontImg, String idCardBackImg, String selfieImg) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.VERIFY_IDENT)
                .params("username", username)
                .params("idCardNo", idCardNo)   // 最开始接口传两个密码
                .params("idCardFrontImg", idCardFrontImg)
                .params("idCardBackImg", idCardBackImg)
                .params("selfieImg", selfieImg);
    }

    @Override
    public PostRequest<HttpData> addPayWay(String payId, String payType, String tradePwd, String wxAccount, String wxImg, String alipayAccount,
                                           String aliImg, String bankCardNo, String bankCardOpenBank, String bankCardType) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADD_PAY_WAY)
                .params("payType", payType)
                .params("payId", payId)
                .params("tradePwd", tradePwd)   // 最开始接口传两个密码
                .params("wxAccount", wxAccount)
                .params("wxImg", wxImg)
                .params("alipayAccount", alipayAccount)
                .params("aliImg", aliImg)
                .params("bankCardNo", bankCardNo)
                .params("bankCardOpenBank", bankCardOpenBank)
                .params("bankCardType", bankCardType);
    }


    //忘记密码
    public static PostRequest<HttpData> forgetPwd(String account, String pswd, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.RESET_PWD)

                .params("opwd", pswd)
                .params("opwd1", pswd)   // 最开始接口传两个密码
                .params("code", code)
                .params("mobile", account)
                .params("pswd", pswd)
                .params("account", account);
    }


    @Override
    public PostRequest<HttpData<AppVersionBean>> getVersion() {
        return OkGo.<HttpData<AppVersionBean>>post(HttpConfig.BASE_URL + HttpConfig.VERSION)

                .params("version", APKVersionCodeUtils.getVerName(MyAppLication.getApplication()))
                .params("appType", "2");
    }

    @Override
    public GetRequest<HttpData<UserInfo>> getUserInfo() {
        return OkGo.<HttpData<UserInfo>>get(HttpConfig.BASE_URL + HttpConfig.GET_USER_INFO)
                .params("id", MyAppLication.getID());
    }


}
